package com.xg.java.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.xg.java.entity.FileShare;
import com.xg.java.service.FileShareService;
import org.apache.commons.lang.time.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Date;

@Component
public class ProjectTask {

    @Autowired
    private FileShareService fileShareService;

    /**
     * 删除过期分享
     */
    @Scheduled(cron = "0 0 1 * * ?")
    public void removeShare(){
        fileShareService.remove(new QueryWrapper<FileShare>().ge("share_time", DateUtils.addDays(new Date(),7)));
    }
}
